extends Item
var ctrl = globalData.infoDs["g_AneHek"]
var v = ["b_lijian","b_bingdong","b_chenshui","b_hl","b_xuanyun"]
func init():
	type = config.EQUITYPE_EQUI
	attInit()
	att.maxHp = 100
	att.def = 10
	att.mgiDef = 10
	att.defR = 0.1
	att.atkRan = 1
	name = "[color=yellow]心之手风琴[/color]"
	info = "[color=red]清除攻击范围内队友身上的<离间><冰冻><眩晕><沉睡><混乱>；若以上状态都没有，则附加1层<闪避提升>[cd:5秒]\n[/color]"

var cnt = 0
var flag = 0

func _connect():
	sys.main.connect("onBattleStart",self,"run")

func run():
	cnt = 0
	flag = 1

func _upS():
	._upS()
	if masCha.isDeath:return
	if !flag:
		flag = 1
		var chas = masCha.getAllChas(1)
		for i in chas:
			if inrange(i.cell,masCha.cell,masCha.att.atkRan):
				var flag2 = 0
				for j in v:
					var bf = i.hasBuff(j)
					if bf:
						bf.isDel = true
						flag2 = 1
				if !flag2:
					i.addBuff(ctrl.b_sbts.new(1))
	#if sys.test:
	#	print(cnt)
	if flag:
		cnt += 1
		if cnt % 5 == 0:
			flag = 0
			cnt = 0

func inrange(a,b,c):
	var x = abs(a.x - b.x)
	var y = abs(a.y - b.y)
	return x*x + y*y <= c*c